import { ColumnProps } from "antd/lib/table";

export const getDateColumns = <D = ColumnProps<unknown>[] | ColumnProps<unknown>>(type?: "updatedTime" | "createdTime") => {
	const columns = [
		{
			title: "更新时间",
			dataIndex: "updatedTime",
			render: (text: string) => new Date(text).toLocaleString(),
		},
		{
			title: "创建时间",
			dataIndex: "createdTime",
			render: (text: string) => new Date(text).toLocaleString(),
		},
	];
	if (!type) return columns as D;
	if (type === "createdTime") return columns[0] as D;
	if (type === "updatedTime") return columns[1] as D;
	return [] as D;
};
